package com.jic.member.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.MememberIntegralGiveConsume;
import com.jic.member.mapper.MememberIntegralGiveConsumeMapper;
import com.jic.member.service.MememberIntegralGiveConsumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会员积分注册赠送-消费抵现表
 * @author : 
 * @email : 
 * @since : 2020-04-02 03:31:41
 * @version : v1.0.0
 */
@Service
public class MememberIntegralGiveConsumeServiceImpl implements MememberIntegralGiveConsumeService {

    @Autowired
    private MememberIntegralGiveConsumeMapper mememberIntegralGiveConsumeMapper;

    @Override
    public long insert(MememberIntegralGiveConsume mememberIntegralGiveConsume) {
        long flag = mememberIntegralGiveConsumeMapper.insert(mememberIntegralGiveConsume);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mememberIntegralGiveConsumeMapper.delete(id);
    }

    @Override
    public long update(MememberIntegralGiveConsume mememberIntegralGiveConsume) {
        return mememberIntegralGiveConsumeMapper.update(mememberIntegralGiveConsume);
    }

    @Override
    public MememberIntegralGiveConsume queryByPrimaryKey(Long id){
        return mememberIntegralGiveConsumeMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MememberIntegralGiveConsume> query(MememberIntegralGiveConsume mememberIntegralGiveConsume){
        return mememberIntegralGiveConsumeMapper.query(mememberIntegralGiveConsume);
    }

    @Override
    public PageResult<MememberIntegralGiveConsume> queryPage(MememberIntegralGiveConsume mememberIntegralGiveConsume, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MememberIntegralGiveConsume> list = mememberIntegralGiveConsumeMapper.queryPage(startIndex, pageQuery.getLimit(), mememberIntegralGiveConsume);
        long count = mememberIntegralGiveConsumeMapper.queryPageCount(mememberIntegralGiveConsume);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}